package com.qqtech.qquan.hi.controller;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtech.core.common.annotation.VisitAnnt;
import com.qqtech.core.common.enums.RespEnum;
import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.model.Result;
import com.qqtech.core.frame.service.BaseService;
import com.qqtech.qquan.hi.model.HiRule;
import com.qqtech.qquan.hi.model.HiRuleQuery;
import com.qqtech.qquan.hi.model.HiRuleVo;
import com.qqtech.qquan.hi.service.HiRuleService;
import com.qqtech.web.context.BaseWebController;

@Controller
@RequestMapping(value = "/hi/rule")
public class HiRuleController extends BaseWebController<HiRule, HiRuleQuery> {
	@Resource
	private HiRuleService hiRuleService;
    
	@Override
	protected BaseService<HiRule> getBaseService() {
		return hiRuleService;
	}
	
	/**
	 * 分页
	 * 
	 * @param HiRuleQuery
	 * @return
	 */
	@VisitAnnt(type = RespEnum.LOGIN)
	@RequestMapping(value = "/page")
	@ResponseBody
	public Result page(@RequestBody HiRuleQuery query) {
		Result ret = new Result();
		Pageable pageKit = new PageKit(query.getPage(), new PageOrder(Direction.DESC, "id"));
		Page<HiRuleVo> page = hiRuleService.queryPageList(query, pageKit);
		ret.put("page", page);
		return ret;
	}
}
